package com.ctshk.sapp.order.hotel.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.hotel.dto.HotelOrderDetailDTO;
import com.ctshk.rpc.hotel.req.HotelPayOrderCollectionReq;
import com.ctshk.rpc.hotel.service.IHotelOrderCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 酒店收款明细 前端控制器
 * </p>
 *
 * @author yinhuan
 * @since 2021-03-08
 */
@Api(value = "酒店收款",tags = "酒店收款")
@RestController
@RequestMapping("/hotel/order/collection")
public class HotelOrderCollectionController extends BaseController {
    @DubboReference
    IHotelOrderCollectionService hotelOrderCollectionService;

    /**
     * 酒店收款明细-再次确认
     * @param collectionId 收款明细id
     * @return
     */
    @ApiOperation(value = "酒店收款明细-再次确认", notes = "酒店收款明细-再次确认")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "酒店收款明细-再次确认", operDesc = "酒店收款明细-再次确认")
    @GetMapping(value = "/confirm/{collectionId}")
    public Result confirm(@PathVariable Long collectionId){
        return hotelOrderCollectionService.confirm(collectionId,getCurrentUser(getRequest()).getId());
    }

    /**
     * 酒店收款明细-查询
     * @param orderId 订单id
     * @return
     */
    @ApiOperation(value = "酒店收款明细-再次确认", notes = "酒店收款明细-再次确认")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "酒店收款明细-再次确认", operDesc = "酒店收款明细-再次确认")
    @GetMapping(value = "/queryDetail/{orderId}")
    public Result<HotelOrderDetailDTO> queryDetail(@PathVariable Long orderId){
        return hotelOrderCollectionService.queryDetail(orderId,getCurrentUser(getRequest()).getId());
    }

    /**
     * 修改收款明细备注
     * @param collectionReq
     * @return
     */
    @ApiOperation(value = "订单中心酒店票退款记录-删除", notes = "订单中心酒店票退款记录-删除")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "订单中心酒店票退款记录-删除", operDesc = "订单中心酒店票退款记录-删除")
    @PostMapping(value = "/collection/update")
    public Result update(@RequestBody @Valid HotelPayOrderCollectionReq collectionReq){
        return hotelOrderCollectionService.update(collectionReq,getCurrentUser(getRequest()).getId());
    }
}
